<?php
/**
 * prepend_gui.php
 *
 * This file is prepended on every file and is responsible to setup
 * the GUI environment (HTML Header) and initialize common classes
 *
 * @category   icestorm
 * @package    ICESTORM
 * @author     Magnus Jonsson <magnus.jonsson@codealliance.se>
 * @author     Hannes Magnusson <hannes.magnusson@gmail.com
 * @copyright  2008 Team babel
 * @license    LGPL
 */
include_once($ROOT_DIR . 'includes/babel/prepend_no_gui.php');

$obj_tpl->setFile("header","babel/header.html");

/**
 * Breadcrumb Builder
 */
$breadcrumb = array();
if (isset($_SESSION['user'])) {
	$breadcrumb = array($_SESSION['user']['username'] => "/go/babel/profile");
	$breadcrumb['babel'] = "/go/babel";
}
if (isset($user_page) && $user_page != 'babel') {
	$breadcrumb[$user_page] = "/go/babel/profile";
	if (isset($_GET['action'])) {
		$breadcrumb[$_GET['action']] = "{$breadcrumb[$user_page]}/{$_GET['action']}";
	}
}
$name = "Unknown";
if (isset($_SESSION["user"])) {
	$name = $_SESSION['user']['profile']['first_name'].' '.$_SESSION['user']['profile']['last_name'];
}

$obj_tpl->setVar(array(
	'SYS_IMAGE_URL'				=> _ICE_IMAGE_URL,
	'SYS_CSS_URL'				=> _ICE_CSS_URL,
	'SYS_JS_URL'				=> _ICE_JS_URL,
	'VAR_LOGGED_IN_AS'			=> $name,
	'VAR_BREADCRUMB'			=> $obj_html->composeBreadcrumb($breadcrumb),
	'VAR_USERNAME'				=> isset($_SESSION['user']['username']) ? $_SESSION['user']['username'] : null,
	'VAR_DEBUG_OUTPUT'			=> (!isLive())?'<a href="#" style="float:left;posiation:absolute;" onclick="javascript:showTable(\'debug_output\',\'whatsnewicon\');"><img src="'._ICE_IMAGE_URL.'downbox.gif" border="0" id="whatsnewicon" align="absmiddle"></a>':'',
	));

$obj_tpl->setBlock("header", "ADDITIONAL_JS", "ADDITIONAL_JS_ref");
if (isset($ADDITIONAL_JS) && is_array($ADDITIONAL_JS)) {

	foreach($ADDITIONAL_JS as $file => $use_root) {
		$obj_tpl->setVar(array(
			"RELATIVE_PATH" => $file,
			"JS_URL"    => $use_root ? _ICE_JS_URL : "",
		));
		$obj_tpl->parse("ADDITIONAL_JS_ref", "ADDITIONAL_JS", true);
	}
}

$obj_tpl->setBlock("header", "ADDITIONAL_CSS", "ADDITIONAL_CSS_ref");
if (isset($ADDITIONAL_CSS) && is_array($ADDITIONAL_CSS)) {

	foreach($ADDITIONAL_CSS as $file => $use_root) {
		$obj_tpl->setVar(array(
			"RELATIVE_PATH" => $file,
			"CSS_URL"    => $use_root ? _ICE_CSS_URL : "",
		));
		$obj_tpl->parse("ADDITIONAL_CSS_ref", "ADDITIONAL_CSS", true);
	}
}


$obj_tpl->parse("header","header");
$obj_tpl->p("header");
?>

